package club.cearnach.api.service;

import club.cearnach.entity.User;
import club.cearnach.api.exception.UserException;
import club.cearnach.api.exception.RoleNotFoundException;
import club.cearnach.api.form.PageBean;
import club.cearnach.security.enumeration.RoleEnum;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.util.List;
import java.util.Optional;


/**
 * @author 阮胜
 * @date 2018/5/26 14:26
 */
public interface IUserService {
    void delete(Integer id) throws UserException;

    User save(User user);

    User find(String account, String password) throws UserException;

    Optional<User> findByAccount(String account);

    Optional<User> findByAccountAndPrivilege(String account, RoleEnum roleEnum) throws RoleNotFoundException;

    User find(Integer id) throws UserException;

    User find(User user) throws UserException;

    Page<User> findAllOrderByCreateDate(PageBean pageBean);

    Page<User> findAll(Pageable pageable);


    List<User> findByIdIn(Integer... ids);

    void deleteIn(Integer... ids);

    long count();

    boolean isExist(String account, Integer id);

    Optional<User> login(String account, String pwd);

    Page<User> findByLastLoginDate();

    Optional<User> findByAccountAndEmail(String account, String email);
}
